module PlanesAccionesHelper
  def clase_grouped_options
    grouped_options = {
      'Incidentes' => Incidente.find_all_by_funcionario_id(@usuario).map(&incidente_option_for_select),
      'Evaluaciones' => Evaluado.find_all_by_usuario_id_and_evaluado_id([current_user,@usuario],@usuario).map(&evaluados_option_for_select)
    }
    grouped_options_for_select(grouped_options,"#{@plan_accion.clase_id}-#{@plan_accion.clase_type}","Seleccione una opcion.") # this is a Rails form helper method
  end

  private

  def incidente_option_for_select
    lambda {|record| [record.descripcion, "#{record.id}-#{record.class.name}"] }
  end
  
  def evaluados_option_for_select
    lambda {|record| [record.nombre, "#{record.id}-#{record.class.name}"] }
  end
end
